@include('widget.admin.adminnav',['url'=>'/index.php/admin/user/list','name'=>$type=='edit'?'编辑管理员':'添加管理员','title'=>'用户管理'])
<form class="form-horizontal" role="form" id="adminMessage">
    <div class="form-group">
        <label for="username" class="col-sm-2 control-label">用户名</label>
        <input type="hidden" name="id" value="{{$id or 'new'}}">
        <div class="col-sm-6">
            <input type="text" class="form-control" id="username" name="username" value="{{$username or ''}}" placeholder="请输入用户名">
        </div>
    </div>
    <div class="form-group">
        <label for="password" class="col-sm-2 control-label">密码</label>
        <div class="col-sm-6">
            <input type="password" class="form-control" id="password" name="password" value="" placeholder="请输入密码">
        </div>
    </div>
    <div class="form-group">
        <label for="repassword" class="col-sm-2 control-label">重复密码</label>
        <div class="col-sm-6">
            <input type="password" class="form-control" id="repassword" name="repassword" value="" placeholder="请再次输入">
        </div>
    </div>
    <div class="form-group">
        <label for="email" class="col-sm-2 control-label">邮箱</label>
        <div class="col-sm-6">
            <input type="text" class="form-control" id="email" name="email" value="{{$email or ''}}" placeholder="请输入邮箱">
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="button" class="btn btn-primary" onclick="userHandler()">提交</button>
            <button type="reset" class="btn btn-default">重填</button>
        </div>
    </div>
</form>
<script>
    function userHandler(event) {
        var event = event || window.event;
        event.preventDefault(); // 兼容标准浏览器
        window.event.returnValue = false; // 兼容IE6~8
        var _data = $("#adminMessage").serialize();
        _data = decodeURIComponent(_data,true);
        var Url="/index.php/admin/user/save";
        dialog.confirm("确认保存？",function callback(){
            $.ajax({
                type:"post",
                data:_data,
                url:Url,
                dataType:"json",
                success:function(data){
                    if(data.res==1){
                        var _url="/index.php/admin/user/list";
                        dialog.success("操作成功！",_url);
                    }else{
                        dialog.error(data.msg);
                    }
                }
            });
        });
    }
</script>